import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import obfuscator from 'rollup-plugin-obfuscator';

export default {
  input: 'src/index.js',
  output: [
    {
      file: 'dist/miniapp.js',
      format: 'umd',
      name: 'MiniApp'
    },
    {
      file: 'dist/miniapp.esm.js',
      format: 'es'
    }
  ],
  plugins: [
    resolve(),
    commonjs(),
    babel({
      babelHelpers: 'bundled',
      presets: ['@babel/preset-env']
    }),
    terser(),
    obfuscator({
      globalOptions: {
        rotateUnicodeArray: true,
        stringArray: true,
        stringArrayEncoding: ['base64'],
        seed: 0 // 使用固定的种子以确保构建的一致性
      }
    })
  ]
};